# 构建器
FROM python:3.13-slim as builder

# 工作目录
WORKDIR /app

# 拷贝必要文件
COPY pyproject.toml .
COPY src/ ./src/

# 开始安装uv并构建
RUN pip install uv -i https://mirrors.aliyun.com/pypi/simple/ \
    && uv build --wheel

# 运行阶段
FROM python:3.13-slim

# 工作目录
WORKDIR /app

# 拷贝构建后的whl
COPY --from=builder /app/dist/example-0.1.0-py3-none-any.whl ./example-0.1.0-py3-none-any.whl

RUN pip install --no-cache-dir ./*.whl -i https://mirrors.aliyun.com/pypi/simple/ \
    && rm -rf ./*.whl

EXPOSE 8000

# 运行
CMD ["uvicorn", "example.main:app", "--host", "0.0.0.0","--port","8000"]